package com.deveye.qrcode;

import com.deveye.model.AccessToken;
import com.deveye.model.QRCode;
import com.deveye.util.WeixinUtil;
import net.sf.json.JSONObject;

/**
 * 生成微信二维码
 */
public class QrCodeApi {

    private static String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKENPOST";

    public static String getQeCode(AccessToken accessToken, String params){
        System.out.print(accessToken.getToken());
        String at = url.replace("TOKENPOST",accessToken.getToken());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("expire_seconds",604800);
        jsonObject.put("action_name","QR_LIMIT_STR_SCENE");
        JSONObject jsonObject1 = new JSONObject();
        JSONObject jsonObject2 = new JSONObject();
        jsonObject2.put("scene_str",params);
        jsonObject1.put("scene",jsonObject2);
        jsonObject.put("action_info",jsonObject1);
        String result = WeixinUtil.httpRequest(at,"POST",jsonObject.toString()).toString();
        return result;
    }
}
